package com.itheima.IO流.字节缓冲流;

import java.io.*;


public class BufferedDemo {
    public static void main(String[] args) throws IOException {
        long start = System.currentTimeMillis();

       // Buffered01();//9
       /* BufferedInputStream du = new BufferedInputStream(new FileInputStream("D:\\J\\my_project\\test.txt"));
        BufferedOutputStream xie = new BufferedOutputStream(new FileOutputStream("D:\\J\\my_project\\a\\test.txt"));

        byte[]bys=new byte[1024];
        int len;

        while ((len=du.read())!=-1){

        }*/

        long end = System.currentTimeMillis();
        System.out.println(end-start);
    }

    private static void Buffered01() throws IOException {
        //基于缓冲字节流一次读写一个字节的方式实现
        //创建输入输出对象
        BufferedInputStream du = new BufferedInputStream(new FileInputStream("D:\\J\\my_project\\test.txt"));
        BufferedOutputStream xie = new BufferedOutputStream(new FileOutputStream("D:\\J\\my_project\\a\\test.txt"));
        //定义临时变量，作为数据传输的载体
        int b;
        //循环读写
        while ((b=du.read())!=-1){
            xie.write(b);
        }
        //关流释放
        du.close();
        xie.close();
    }


}
